package com.company.process;

import com.company.TrianglePacket;
import com.company.graph.Graph;
import com.company.graph.NopowerNoDirectNodeGraph;
import com.company.graphgetter.GraphGetter;
import com.company.graphgetter.NodeGetterWithGraph;

import java.time.LocalDateTime;

public class GraphBAProcess implements GraphProcess {
    int LUMBDA;
    NopowerNoDirectNodeGraph G;
    NodeGetterWithGraph GFG;

    public GraphBAProcess(int lumbda) {
        LUMBDA = lumbda;
    }


    @Override
    public void process(Graph graph, GraphGetter getter) {
        G = (NopowerNoDirectNodeGraph) graph;
        GFG = (NodeGetterWithGraph) getter;
        while (true) {
            System.out.println("-----------------");
            System.out.println(LocalDateTime.now());
            TrianglePacket rank = GFG.getTopRank();
            int v = rank.getId();
            int triangle = rank.getValue();
            System.out.println(triangle);
            if (triangle > LUMBDA) {
                int w = GFG.getMaxTriangleEdgeNeighbor(v);
                G.deleteEdgeWithTriangle(v, w, GFG);
            } else {
                break;
            }
        }
    }
}
